import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);
const router = new VueRouter({
  base: './',
  // mode: 'hash',
  routes: [
    {
      path: "/",
      name: "main",
      redirect: "/home",
    },
    {
      path: "/home",
      name: "home",
      component: () => import('../views/home.vue'),
      meta: {title: "home", showTitle: false}
    },
    {
      path: "/database",
      name: "database",
      component: () => import('../views/database/database.vue'),
      meta: {title: "数据管理", showTitle: false}
    },
    {
      path: "/print",
      name: "print",
      component: () => import('../views/print/print.vue'),
      meta: {title: "发票打印", showTitle: false}
    },
  ],
});
/**
 *  在进入路由之前每次都会执行此方法 全局钩子
 */
router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});
router.afterEach(function (to) {
});
export default router;
